﻿using System;
using System.Collections.Generic;

namespace RbmlVisualizer.Logging
{
    public interface ILoggingService
    {
        /// <summary>
        /// Fired when a message is logged by the system.
        /// </summary>
        event EventHandler<MessageLoggedEventArgs> MessageLogged;

        /// <summary>
        /// Gets and sets the log level.
        /// </summary>
        LogLevelType LogLevel { get; set; }

        /// <summary>
        /// Determines if logging is currently enabled for the given log type.
        /// </summary>
        bool IsLoggingEnabledFor(LogLevelType level);

        //IList<string> LoggingMessages { get; }

        IList<LogMessage> GetLoggingMessagesForLevel(LogLevelType levelType);

        void Clear();

        void WriteDebug(Func<string> createMessageDelegate);

        void WriteInfo(Func<string> createMessageDelegate);

        void WriteError(Func<string> createMessageDelegate);

        void WriteInfo(string format, params object[] args);
        void WriteInfo(string message);

        void WriteDebug(string format, params object[] args);
        void WriteDebug(string message);

        void WriteError(string format, params object[] args);
        void WriteError(string message);

        void WriteException(Exception exception, string message);
        void WriteException(Exception exception, string format, params object[] args);
    }

    /// <summary>
    /// Event args class for logging events.
    /// </summary>
    public class MessageLoggedEventArgs : EventArgs
    {
        /// <summary>
        /// Creates a new event args.
        /// </summary>
        public MessageLoggedEventArgs(LogMessage message)
        {
            Message = message;
        }

        /// <summary>
        /// The message that was logged.
        /// </summary>
        public LogMessage Message { get; private set; }
    }
}
